
import Debug.QuickCheck

data Suit = Spades | Hearts | Diamonds | Clubs
 deriving ( Show )

data Colour = Black | Red
 deriving ( Show )

colour :: Suit -> Colour
colour Spades   = Black
colour Hearts   = Red
colour Diamonds = Red
colour Clubs    = Black

data Rank = Numeric Integer | Jack | King | Queen | Ace
 deriving ( Eq, Show )

rankBeats :: Rank -> Rank -> Bool
rankBeats _           Ace         = False
rankBeats Ace         _           = True
rankBeats _           King        = False
rankBeats King        _           = True
rankBeats _           Queen       = False
rankBeats Queen       _           = True
rankBeats _           Jack        = False
rankBeats Jack        _           = True
rankBeats (Numeric m) (Numeric n) = m > n

prop_RankBeats a b =
  a /= b ==>
    rankBeats a b || rankBeats b a

instance Arbitrary Rank where
  arbitrary =
    oneof $
      [ do return c
      | c <- [Jack,Queen,King,Ace]
      ] ++
      [ do n <- choose (2,10)
           return (Numeric n)
      ] 

